home *** CD-ROM | disk | FTP | other *** search
-
- //
- // Description:
- // Sample Tool Bar class. Implements basic functionality for all toolbars.
- // Creates a window with a horizontal or vertical packer. Defines method 'AddTool'
- // which allows derived classes to insert tool buttons + associated callbacks
- // easily.
- //
- // Super class:
- // oops/r3window.js
- //
- // Constructor:
- // toolbar = new myToolbar(String name, Integer Orientation);
- //
- // Methods:
- // AddTool(String name, function callback);
- //
-
- include("oops/r3button.js");
- include("oops/r3window.js");
- include("oops/r3packer.js");
-
- // Orientation codes
-
- var VERTICAL = R3PAOF_VERTICAL;
- var HORIZONTAL = R3PAOF_HORIZONTAL;
-
-
- // method for adding tools
-
- function mytbAddTool(text, callback)
- {
- // create a button with given label
- button = new r3Button(R3RA_Hook, callback,
- R3WGA_Parent, this,
- R3GA_Text, text);
-
- if(button) {
- // insert the button into the packer
- this.packer.ADD(R3PAPF_FILLX, 0, button);
-
- // tell the button where to find geometric objects
- button.layer = this.layer;
- return TRUE;
- }
- else
- return FALSE;
- }
-
- // Constructor
-
- function myToolBar(titlebar, orientation, layer)
- {
- if(arguments.length == 0)
- return;
- this.base = r3Window;
-
- // let the super class to do its job
- this.base(R3WGA_Left, 200,
- R3WGA_Top, 150,
- R3WA_ReportNewSize, TRUE,
- R3WA_ReportCloseWindow, TRUE,
- R3WA_Title, titlebar);
-
- // Create a packer for managing toolbar layout
- this.packer = new r3Packer(0);
- this.packer.SetOrientation(orientation);
-
- // layer to be manipulated by the tools in this tool bar
- this.layer = layer;
-
- // method for inserting tool buttons
- this.AddTool = mytbAddTool;
-
- // and give the packer to the window
- this.SetGmanager(this.packer);
- }
-
- myToolBar.prototype=new r3Window;
-
-